

<!DOCTYPE html>
<html lang="en" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/myblog/img/favicon.png">
  <link rel="icon" type="image/png" href="/myblog/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="John Doe">
  <meta name="keywords" content="">
  <title>filnk-01 - Hexo</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/myblog/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.4.0/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
  



<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/myblog/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"menmingyuan.gitee.io","root":"/myblog/","version":"1.8.7","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"onlypost":false},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null}}};
  </script>
  <script  src="/myblog/js/utils.js" ></script>
  <script  src="/myblog/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.3.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/myblog/">&nbsp;<strong>Fluid</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/">
                <i class="iconfont icon-home-fill"></i>
                Home
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                Archives
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/categories/">
                <i class="iconfont icon-category-fill"></i>
                Categories
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                Tags
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/about/">
                <i class="iconfont icon-user-fill"></i>
                About
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/myblog/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="filnk-01">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2020-07-31 21:00" pubdate>
        July 31, 2020 pm
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      3.9k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      54
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">filnk-01</h1>
            
              <p class="note note-info">
                
                  本文最后更新于：October 9, 2020 pm
                
              </p>
            
            <div class="markdown-body">
              <h1 id="flink-note01"><a href="#flink-note01" class="headerlink" title="flink note01"></a>flink note01</h1><h2 id="flink简介"><a href="#flink简介" class="headerlink" title="flink简介"></a>flink简介</h2><h3 id="flink引入"><a href="#flink引入" class="headerlink" title="flink引入"></a>flink引入</h3><p>大数据技术框架发展阶段</p>
<p>总共有四代，mr–&gt;DAG框架（tez）—&gt;Spark流批处理框架，内存计算（伪实时）–&gt;flink流批处理，内存计算（真正的实时计算）</p>
<p>flink vs spark</p>
<p><img src="assets/image-20200415105119792.png" srcset="/myblog/img/loading.gif" alt="image-20200415105119792"></p>
<h3 id="什么是flink"><a href="#什么是flink" class="headerlink" title="什么是flink"></a>什么是flink</h3><p>flink是一个分布式，高性能，随时可用的以及准确的流处理计算框架，</p>
<p>flink可以对<strong>无界数据</strong>（流处理）和<strong>有界数据</strong>（批处理）进行有<strong>状态计算</strong>（flink天生支持状态计算）的分布式，高性能的计算框架。</p>
<h3 id="flink流处理特性"><a href="#flink流处理特性" class="headerlink" title="flink流处理特性"></a>flink流处理特性</h3><p><img src="assets/image-20200415110408410.png" srcset="/myblog/img/loading.gif" alt="image-20200415110408410"></p>
<h3 id="flink的基石"><a href="#flink的基石" class="headerlink" title="flink的基石"></a>flink的基石</h3><p>flink的四大基石：<strong>checkpoint,state,time,window</strong></p>
<p>checkpoint:基于chandy-lamport算法实现分布式计算任务的一致性语义；</p>
<p>state:flink中的状态机制，flink天生支持state,state可以认为程序的中间计算结果或者是历史计算结果；</p>
<p>time:flink中支持基于事件时间和处理时间进行计算，spark streaming只能按照process time进行处理；</p>
<p>基于事件时间的计算我们可以解决数据迟到和乱序等问题。</p>
<p>window:flink提供了更多丰富的window,基于时间，基于数量，session window,同样支持滚动和滑动窗口的计算。</p>
<h3 id="flink流处理和批处理"><a href="#flink流处理和批处理" class="headerlink" title="flink流处理和批处理"></a>flink流处理和批处理</h3><p>流处理：无界，实时性有要求，只需对经过程序的每条数据进行处理</p>
<p>批处理：有界，持久，需要对全部数据进行访问处理；</p>
<p>spark vs flink</p>
<p>spark：spark生态中是把所有的计算都当做批处理，spark streaming中流处理本质上也是批处理（micro batch）;</p>
<p>flink：flink中是把批处理（有界数据集的处理）看成是一个特殊的流处理场景；flink中所有计算都是流式计算；</p>
<p>flink中技术栈</p>
<p><img src="assets/image-20200415112706997.png" srcset="/myblog/img/loading.gif" alt="image-20200415112706997"></p>
<h2 id="flink架构体系"><a href="#flink架构体系" class="headerlink" title="flink架构体系"></a>flink架构体系</h2><h3 id="flink中重要角色"><a href="#flink中重要角色" class="headerlink" title="flink中重要角色"></a>flink中重要角色</h3><p>JobManager:类似spark中master，负责资源申请，任务分发，任务调度执行，checkpoint的协调执行；可以搭建HA，双master。</p>
<p>TaskManager:类似spark中的worker，负责任务的执行，基于dataflow(spark中DAG)划分出的task;与jobmanager保持心跳，汇报任务状态。</p>
<p><img src="assets/image-20200415121624466.png" srcset="/myblog/img/loading.gif" alt="image-20200415121624466"></p>
<h3 id="无界数据和有界数据"><a href="#无界数据和有界数据" class="headerlink" title="无界数据和有界数据"></a>无界数据和有界数据</h3><p>无界数据流：数据流是有一个开始但是没有结束；</p>
<p>有界数据流：数据流是有一个明确的开始和结束，数据流是有边界的。</p>
<p>flink处理流批处理的思想是：</p>
<p>flink支持的runtime(core 分布式流计算)支持的是无界数据流，但是对flink来说可以支持批处理，只是从数据流上来说把有界数据流只是无界数据流的一个特例，无界数据流只要添加上边界就是有界数据流。</p>
<h3 id="flink编程模型"><a href="#flink编程模型" class="headerlink" title="flink编程模型"></a>flink编程模型</h3><p>flink提供了四种编程模型，分别应对我们不同的场景：</p>
<p><img src="assets/image-20200415123517084.png" srcset="/myblog/img/loading.gif" alt="image-20200415123517084"></p>
<p>flink中四种api可以混合使用，无缝的切换。</p>
<p>从数据结构和api层面比对flink和spark</p>
<p>spark vs flink</p>
<p><img src="assets/image-20200415123930994.png" srcset="/myblog/img/loading.gif" alt="image-20200415123930994"></p>
<h2 id="flink集群搭建"><a href="#flink集群搭建" class="headerlink" title="flink集群搭建"></a>flink集群搭建</h2><h3 id="flink的安装模式"><a href="#flink的安装模式" class="headerlink" title="flink的安装模式"></a>flink的安装模式</h3><p>三种：</p>
<p>local:单机模式，尽量不使用</p>
<p>standalone:flink自带集群，资源管理由flink集群管理</p>
<p>flink on yarn: 把资源管理交给yarn实现。</p>
<p><img src="assets/image-20200415124521431.png" srcset="/myblog/img/loading.gif" alt="image-20200415124521431"></p>
<p>安装环境准备：</p>
<p>jdk1.8及以上版本，免密登录；</p>
<p>flink的安装包：</p>
<p>flink 1.7.2版本，从资料中获取安装包</p>
<h4 id="local模式-很少使用"><a href="#local模式-很少使用" class="headerlink" title="local模式 很少使用"></a>local模式 很少使用</h4><p>a 上传安装包然后解压到指定目录,注意修改所属用户和用户组</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs shell">tar -zxvf flink-1.7.2-bin-hadoop27-scala_2.11.tgz <br>mv flink-1.7.2 flink<br>chown -R root:root flink<br></code></pre></td></tr></table></figure>
<p>b 去flink的bin目录下启动shell交互式窗口</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/start-scala-shell.sh local<br></code></pre></td></tr></table></figure>
<p>c 提交一个任务</p>
<figure class="highlight scala"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs scala">benv.readTextFile(<span class="hljs-string">&quot;/root/words.txt&quot;</span>).flatMap(_.split(<span class="hljs-string">&quot; &quot;</span>)).map((_,<span class="hljs-number">1</span>)).groupBy(<span class="hljs-number">0</span>).sum(<span class="hljs-number">1</span>).print()<br></code></pre></td></tr></table></figure>


<p>启动scala-shell的现象flink准备了benv,senv,分别是批处理和流处理程序入口对象</p>
<p><img src="assets/image-20200415141047021.png" srcset="/myblog/img/loading.gif" alt="image-20200415141047021"></p>
<p>单节点的flink集群</p>
<p>a 直接启动</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/start-cluster.sh<br></code></pre></td></tr></table></figure>
<p>验证这两个进程是否存在：</p>
<p><img src="assets/image-20200415141609336.png" srcset="/myblog/img/loading.gif" alt="image-20200415141609336"></p>
<p>c flink web ui</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">http://node1:8081<br></code></pre></td></tr></table></figure>
<p><img src="assets/image-20200415142136876.png" srcset="/myblog/img/loading.gif" alt="image-20200415142136876"></p>
<p>d 提交任务到flink 单节点集群:统计/root/words.txt中的单词数量，（准备数据文件）</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">/export/servers/flink/bin/flink run /export/servers/flink/examples/batch/WordCount.jar --input /root/words.txt --output /root/out2<br></code></pre></td></tr></table></figure>
<p>注意：</p>
<p>自己练习如果来回切换模式时可能会遇到提交任务报错的情况：</p>
<p>如失败需删除之前的运行信息</p>
<p>rm -rf /tmp/.yarn-properties-root</p>
<p>e 停止集群</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/stop-cluster.sh<br></code></pre></td></tr></table></figure>


<h4 id="standalone模式"><a href="#standalone模式" class="headerlink" title="standalone模式"></a>standalone模式</h4><p>原理：</p>
<p><img src="assets/image-20200415150822314.png" srcset="/myblog/img/loading.gif" alt="image-20200415150822314"></p>
<p>a 修改配置文件 conf/flink-conf.yaml</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs pro">jobmanager.rpc.address: node1<br>jobmanager.rpc.port: 6123<br>jobmanager.heap.size: 1024<br>taskmanager.heap.size: 1024<br>taskmanager.numberOfTaskSlots: 2<br>taskmanager.memory.preallocate: false<br>parallelism.default: 1<br>jobmanager.web.port: 8081<br>taskmanager.tmp.dirs: &#x2F;export&#x2F;servers&#x2F;flink&#x2F;tmp<br>web.submit.enable: true<br></code></pre></td></tr></table></figure>
<p>b 修改master文件 conf/master</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs pro">node1:8081<br></code></pre></td></tr></table></figure>
<p>c 修改conf目录下slave文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs pro">node1<br>node2<br>node3<br></code></pre></td></tr></table></figure>
<p>d 配置hadoop_conf_dir到/etc/profile中，是flink on yarn的时候使用</p>
<p>e 分发flink目录到其它节点</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs shell"> scp -r /export/servers/flink node2:/export/servers/flink<br> scp -r /export/servers/flink node3:/export/servers/flink<br>scp -r /etc/profile node2:/etc/profile<br> scp -r /etc/profile node3:/etc/profile<br></code></pre></td></tr></table></figure>
<p>f 启动集群</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/start-cluster.sh 停止 bin/stop-cluster.sh<br></code></pre></td></tr></table></figure>
<p>单独启动jobmanager或者taskmanager</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/jobmanager.sh start/stop<br>bin/taskmanager.sh start/stop<br></code></pre></td></tr></table></figure>
<p>h提交任务到standalone集群</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">/export/servers/flink/bin/flink run  /export/servers/flink/examples/batch/WordCount.jar <br>--input hdfs://node1:8020/wordcount/input/words.txt --output hdfs://node1:8020/wordcount/output/result.txt  --parallelism 2<br></code></pre></td></tr></table></figure>
<p>注意：使用的数据文件是hdfs上，不能是本地文件路径，因为会找不到文件。</p>
<h5 id="standalone-HA集群搭建"><a href="#standalone-HA集群搭建" class="headerlink" title="standalone HA集群搭建"></a>standalone HA集群搭建</h5><p>解决standalone集群的单点故障问题，所以搭建HA集群。</p>
<p>原理：</p>
<p><img src="assets/image-20200415153743317.png" srcset="/myblog/img/loading.gif" alt="image-20200415153743317"></p>
<p>引入zookeeper来完成双主节点，主从切换工作。</p>
<p>具体步骤：</p>
<p>a 停止原先standalone集群</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/stop-cluster.sh<br></code></pre></td></tr></table></figure>
<p>b 修改conf/flink-conf.yaml</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs pro">state.backend: filesystem<br>state.backend.fs.checkpointdir: hdfs:&#x2F;&#x2F;node1:8020&#x2F;flink-checkpoints<br>high-availability: zookeeper<br>high-availability.storageDir: hdfs:&#x2F;&#x2F;node1:8020&#x2F;flink&#x2F;ha&#x2F;<br>high-availability.zookeeper.quorum: node1:2181,node2:2181,node3:2181<br>high-availability.zookeeper.client.acl: open<br></code></pre></td></tr></table></figure>
<p>配置的解释：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><code class="hljs pro">#开启HA，使用文件系统作为快照存储<br>state.backend: filesystem<br><br>#启用检查点，可以将快照保存到HDFS<br>state.backend.fs.checkpointdir: hdfs:&#x2F;&#x2F;node1:8020&#x2F;flink-checkpoints<br><br>#使用zookeeper搭建高可用<br>high-availability: zookeeper<br><br># 存储JobManager的元数据到HDFS<br>high-availability.storageDir: hdfs:&#x2F;&#x2F;node1:8020&#x2F;flink&#x2F;ha&#x2F;<br><br># 配置ZK集群地址<br>high-availability.zookeeper.quorum: node1:2181,node2:2181,node3:2181<br><br># 默认是 open，如果 zookeeper security 启用了更改成 creator<br>high-availability.zookeeper.client.acl: open<br><br># 设置savepoints 的默认目标目录(可选)<br># state.savepoints.dir: hdfs:&#x2F;&#x2F;namenode-host:port&#x2F;flink-checkpoints<br><br># 用于启用&#x2F;禁用增量 checkpoints 的标志<br># state.backend.incremental: false<br></code></pre></td></tr></table></figure>
<p>c 配置master</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs pro">node1:8081<br>node2:8081<br></code></pre></td></tr></table></figure>
<p>d 分发master,flink-conf.yaml</p>
<p>e 在node2节点上，修改flink-conf.yaml中jobmanager.rpc.address: node2</p>
<p>f 启动HA集群</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/start-cluster.sh<br></code></pre></td></tr></table></figure>
<p>h 测试</p>
<p>杀死active的jobmanager,然后看standby是否会切换为active状态。</p>
<h3 id="重点：flink-on-yarn"><a href="#重点：flink-on-yarn" class="headerlink" title="重点：flink on yarn"></a>重点：flink on yarn</h3><p>flink on yarn 企业生产环境运行flink任务大多数的选择</p>
<p>好处：集群资源由yarn集群统一调度和管理，提高利用率，flink中jobmanager的高可用操作就由yarn集群来管理实现。</p>
<p>准备工作：</p>
<p>主要是在yarn-site.xml中配置关闭内存校验</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs pro">&lt;property&gt;<br>    &lt;name&gt;yarn.nodemanager.pmem-check-enabled&lt;&#x2F;name&gt;<br>    &lt;value&gt;false&lt;&#x2F;value&gt;<br>&lt;&#x2F;property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;yarn.nodemanager.vmem-check-enabled&lt;&#x2F;name&gt;<br>    &lt;value&gt;false&lt;&#x2F;value&gt;<br>&lt;&#x2F;property&gt;<br></code></pre></td></tr></table></figure>
<p>否则flink任务可能会因为内存超标而被yarn集群主动杀死</p>
<p>flink on yarn 两种模式</p>
<p><img src="assets/image-20200415172546708.png" srcset="/myblog/img/loading.gif" alt="image-20200415172546708"></p>
<h4 id="session-会话模式"><a href="#session-会话模式" class="headerlink" title="session 会话模式"></a>session 会话模式</h4><p><img src="assets/image-20200415172832111.png" srcset="/myblog/img/loading.gif" alt="image-20200415172832111"></p>
<p>使用yarn-session.sh命令申请资源初始化一个flink集群</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/yarn-session.sh -n 2 -tm 800 -s 1 -d<br></code></pre></td></tr></table></figure>
<p># -n 表示申请2个容器，这里指的就是多少个taskmanager</p>
<p># -s 表示每个TaskManager的slots数量</p>
<p># -tm 表示每个TaskManager的内存大小</p>
<p># -d 表示以后台程序方式运行</p>
<p>使用yarn-session.sh –help 查看可用参数：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><code class="hljs pro">Usage:<br>   Required<br>     -n,--container &lt;arg&gt;   Number of YARN container to allocate (&#x3D;Number of Task Managers)<br>   Optional<br>     -D &lt;property&#x3D;value&gt;             use value for given property<br>     -d,--detached                   If present, runs the job in detached mode<br>     -h,--help                       Help for the Yarn session CLI.<br>     -id,--applicationId &lt;arg&gt;       Attach to running YARN session<br>     -j,--jar &lt;arg&gt;                  Path to Flink jar file<br>     -jm,--jobManagerMemory &lt;arg&gt;    Memory for JobManager Container with optional unit (default: MB)<br>     -m,--jobmanager &lt;arg&gt;           Address of the JobManager (master) to which to connect. Use this flag to connect to a different JobManager than the one specified in the configuration.<br>     -n,--container &lt;arg&gt;            Number of YARN container to allocate (&#x3D;Number of Task Managers)<br>     -nl,--nodeLabel &lt;arg&gt;           Specify YARN node label for the YARN application<br>     -nm,--name &lt;arg&gt;                Set a custom name for the application on YARN<br>     -q,--query                      Display available YARN resources (memory, cores)<br>     -qu,--queue &lt;arg&gt;               Specify YARN queue.<br>     -s,--slots &lt;arg&gt;                Number of slots per TaskManager<br>     -sae,--shutdownOnAttachedExit   If the job is submitted in attached mode, perform a best-effort cluster shutdown when the CLI is terminated abruptly, e.g., in response to a user interrupt, such<br>                                     as typing Ctrl + C.<br>     -st,--streaming                 Start Flink in streaming mode<br>     -t,--ship &lt;arg&gt;                 Ship files in the specified directory (t for transfer)<br>     -tm,--taskManagerMemory &lt;arg&gt;   Memory per TaskManager Container with optional unit (default: MB)<br>     -yd,--yarndetached              If present, runs the job in detached mode (deprecated; use non-YARN specific option instead)<br>     -z,--zookeeperNamespace &lt;arg&gt;   Namespace to create the Zookeeper sub-paths for high availability mode<br></code></pre></td></tr></table></figure>


<p>yarn集群中运行的任务：</p>
<p><img src="assets/image-20200415173428942.png" srcset="/myblog/img/loading.gif" alt="image-20200415173428942"></p>
<p>提交任务</p>
<p>flink run</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">/export/servers/flink/bin/flink run /export/servers/flink/examples/batch/WordCount.jar<br></code></pre></td></tr></table></figure>
<p>停止 flink on yarn 会话模式中的flink集群</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">yarn application -kill appid<br></code></pre></td></tr></table></figure>
<p>会话模式这种方式的优缺点：</p>
<p>缺点：1 会一直有一个程序运行在yarn集群中，不管有没有任务提交执行，浪费资源，</p>
<p>优点：flink 集群环境是提前准备好的不需要为每个作业单独创建flink环境</p>
<p>适用场景：大量的小作业的时候可以考虑使用这种方式</p>
<h4 id="job分离模式"><a href="#job分离模式" class="headerlink" title="job分离模式"></a>job分离模式</h4><p>flink run -m yarn-cluster –help;可用参数：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><code class="hljs pro">Options for yarn-cluster mode:<br>     -d,--detached                        If present, runs the job in detached<br>                                          mode<br>     -m,--jobmanager &lt;arg&gt;                Address of the JobManager (master) to<br>                                          which to connect. Use this flag to<br>                                          connect to a different JobManager than<br>                                          the one specified in the<br>                                          configuration.<br>     -sae,--shutdownOnAttachedExit        If the job is submitted in attached<br>                                          mode, perform a best-effort cluster<br>                                          shutdown when the CLI is terminated<br>                                          abruptly, e.g., in response to a user<br>                                          interrupt, such as typing Ctrl + C.<br>     -yD &lt;property&#x3D;value&gt;                 use value for given property<br>     -yd,--yarndetached                   If present, runs the job in detached<br>                                          mode (deprecated; use non-YARN<br>                                          specific option instead)<br>     -yh,--yarnhelp                       Help for the Yarn session CLI.<br>     -yid,--yarnapplicationId &lt;arg&gt;       Attach to running YARN session<br>     -yj,--yarnjar &lt;arg&gt;                  Path to Flink jar file<br>     -yjm,--yarnjobManagerMemory &lt;arg&gt;    Memory for JobManager Container with<br>                                          optional unit (default: MB)<br>     -yn,--yarncontainer &lt;arg&gt;            Number of YARN container to allocate<br>                                          (&#x3D;Number of Task Managers)<br>     -ynl,--yarnnodeLabel &lt;arg&gt;           Specify YARN node label for the YARN<br>                                          application<br>     -ynm,--yarnname &lt;arg&gt;                Set a custom name for the application<br>                                          on YARN<br>     -yq,--yarnquery                      Display available YARN resources<br>                                          (memory, cores)<br>     -yqu,--yarnqueue &lt;arg&gt;               Specify YARN queue.<br>     -ys,--yarnslots &lt;arg&gt;                Number of slots per TaskManager<br>     -yst,--yarnstreaming                 Start Flink in streaming mode<br>     -yt,--yarnship &lt;arg&gt;                 Ship files in the specified directory<br>                                          (t for transfer)<br>     -ytm,--yarntaskManagerMemory &lt;arg&gt;   Memory per TaskManager Container with<br>                                          optional unit (default: MB)<br>     -yz,--yarnzookeeperNamespace &lt;arg&gt;   Namespace to create the Zookeeper<br>                                          sub-paths for high availability mode<br>     -z,--zookeeperNamespace &lt;arg&gt;        Namespace to create the Zookeeper<br>                                          sub-paths for high availability mode<br></code></pre></td></tr></table></figure>


<p>直接提交任务到yarn即可：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">bin/flink run -m yarn-cluster -yn 2 -yjm 1024 -ytm 1024 /export/servers/flink/examples/batch/WordCount.jar<br></code></pre></td></tr></table></figure>
<p>yjm:jobmanager内存</p>
<p>ytm：taskmanager内存</p>
<p>ys：taskmanager slot</p>
<p>yn:taskmanger数量</p>
<p>提交任务之后会在yarn集群按照我们的配置初始化一个flink集群，运行我们提交的作业，作业执行完成之后就释放资源关闭掉flink集群，把资源还给yarn集群。</p>
<p>总结：</p>
<p>优点：随到随用，只有任务需要运行时才会开启flink集群；运行完就关闭释放资源，资源利用更合理；</p>
<p>缺点：对于小作业不太友好，</p>
<p>适用场景：适合大作业，长时间运行的大作业。</p>
<h2 id="flink-运行架构"><a href="#flink-运行架构" class="headerlink" title="flink 运行架构"></a>flink 运行架构</h2><h3 id="flink的编程模型"><a href="#flink的编程模型" class="headerlink" title="flink的编程模型"></a>flink的编程模型</h3><p><img src="assets/image-20200415212320252.png" srcset="/myblog/img/loading.gif" alt="image-20200415212320252"></p>
<h3 id="flink中的并行流"><a href="#flink中的并行流" class="headerlink" title="flink中的并行流"></a>flink中的并行流</h3><p><img src="assets/image-20200415213039762.png" srcset="/myblog/img/loading.gif" alt="image-20200415213039762"></p>
<p>flink中streamdataflow实际是并行化的，</p>
<p>operator并行化也就是有多个并行度，每个并行度就是一个operator subtask;</p>
<p>stream 并行化，会产生stream partition;</p>
<p>flink中operator之间数据是如何分发的？</p>
<p>两种模式：</p>
<p>one to one:一对一模式，上下游算子并行度一致并且数据没有类似shuffle的分发，就保持上游每个streampartition中数据的特性（排序）传递给下游某个分区。</p>
<p>redistributing:重新分区，类似spark中的shuffle操作，数据会在上下游算子不同的subtask中分散。</p>
<h4 id="flink中的task和operator-chain"><a href="#flink中的task和operator-chain" class="headerlink" title="flink中的task和operator chain"></a>flink中的task和operator chain</h4><p><img src="assets/image-20200415215251110.png" srcset="/myblog/img/loading.gif" alt="image-20200415215251110"></p>
<p>flink中把onetoone的operator可以合并为一个operator chain,operator chain他的某个并行度就是一个subtask，</p>
<p>flink中真正调度的任务就是operator chain的subtask.</p>
<h4 id="flink-调度和执行"><a href="#flink-调度和执行" class="headerlink" title="flink 调度和执行"></a>flink 调度和执行</h4><p><img src="assets/image-20200415215707073.png" srcset="/myblog/img/loading.gif" alt="image-20200415215707073"></p>
<p>jobclient:用户编写的代码，flink的客户端封装好的提交任务的客户端；</p>
<p>主要作用：提交任务，不是flink内部的一个角色。接收用户编写的代码，创建streamdataflow，提交给jobmanager，接收任务的执行结果并返回给客户；</p>
<p>jobmanager:负责接收任务，对任务进行优化，并调度和执行任务；主要由调度器和checkpoint coordinator（ck协调器）</p>
<p>taskmanger:从jobmanager中接收task,部署到自己的slot中并执行，tm实际执行任务都是以线程执行（更轻量级），</p>
<p>tm中有配置好的slot,每个slot都可以执行task.</p>
<h4 id="slot-槽-和slot-sharing（槽共享）"><a href="#slot-槽-和slot-sharing（槽共享）" class="headerlink" title="slot(槽)和slot sharing（槽共享）"></a>slot(槽)和slot sharing（槽共享）</h4><p>slot:是flink中从资源层面进行调度的单位，</p>
<p>特点：slot是会平均划分当前tm中内存，flink程序的最大并行度就是所有tm中的slot的数量，（我们flink控制可以接收的任务数量就是通过slot数量来实现）</p>
<p>slot数量如何确定：保持和tm中的cpu核数一样，保证任务执行的性能。</p>
<p>slot实际是任务执行的真正角色。</p>
<p>slot sharing:槽共享，每个slot都可以接收当前作业的不同的子任务，这样充分利用了当前所有slot来提高并行度。</p>
<p><img src="assets/image-20200415221557613.png" srcset="/myblog/img/loading.gif" alt="image-20200415221557613"></p>
<h2 id="flink程序入门案例"><a href="#flink程序入门案例" class="headerlink" title="flink程序入门案例"></a>flink程序入门案例</h2><p>使用scala代码来编写flink程序，虽然flink的源码是java但是也有部分scala代码（scala与java代码混编），使用scala编写程序会比较简洁方便。</p>
<p>1 创建project，创建的是父子工程，pom依赖都在父工程中</p>
<p>2 准备一个log4j.properties</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs pro">log4j.rootLogger&#x3D;INFO, console<br>log4j.appender.console&#x3D;org.apache.log4j.ConsoleAppender<br>log4j.appender.console.layout&#x3D;org.apache.log4j.PatternLayout<br>log4j.appender.console.layout.ConversionPattern&#x3D;%d&#123;HH:mm:ss,SSS&#125; %-5p %-60c %x - %m%n<br></code></pre></td></tr></table></figure>
<p>3 编写wordcount代码</p>
<p>步骤：</p>
<ol>
<li><p>获得一个execution environment，</p>
</li>
<li><p>加载/创建初始数据，</p>
</li>
<li><p>指定这些数据的转换，</p>
</li>
<li><p>指定将计算结果放在哪里，</p>
</li>
<li><p>触发程序执行</p>
</li>
</ol>
<p>参考代码：</p>
<figure class="highlight scala"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><code class="hljs scala"><span class="hljs-keyword">package</span> cn.itcast.flink.batch<br><br><span class="hljs-keyword">import</span> org.apache.flink.api.scala.<span class="hljs-type">ExecutionEnvironment</span><br><span class="hljs-keyword">import</span> org.apache.flink.api.scala._<br><span class="hljs-keyword">import</span> org.apache.flink.core.fs.<span class="hljs-type">FileSystem</span><br><br><span class="hljs-comment">/*</span><br><span class="hljs-comment">使用flink批处理进行单词计数</span><br><span class="hljs-comment"> */</span><br><span class="hljs-class"><span class="hljs-keyword">object</span> <span class="hljs-title">WordCountDemo</span> </span>&#123;<br>  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span></span>(args: <span class="hljs-type">Array</span>[<span class="hljs-type">String</span>]): <span class="hljs-type">Unit</span> = &#123;<br>    <span class="hljs-comment">/*</span><br><span class="hljs-comment">    1.获得一个execution environment，</span><br><span class="hljs-comment">    2.加载/创建初始数据，</span><br><span class="hljs-comment">    3.指定这些数据的转换，</span><br><span class="hljs-comment">    4.指定将计算结果放在哪里，</span><br><span class="hljs-comment">    5.触发程序执行</span><br><span class="hljs-comment">     */</span><br>    <span class="hljs-comment">//  1.获得一个execution environment， 批处理程序入口对象</span><br>    <span class="hljs-keyword">val</span> env: <span class="hljs-type">ExecutionEnvironment</span> = <span class="hljs-type">ExecutionEnvironment</span>.getExecutionEnvironment<br>    <span class="hljs-comment">//设置全局并行度为1，</span><br>    env.setParallelism(<span class="hljs-number">1</span>)<br>    <span class="hljs-comment">// 2.加载/创建初始数据</span><br>    <span class="hljs-keyword">val</span> sourceDs: <span class="hljs-type">DataSet</span>[<span class="hljs-type">String</span>] = env.fromElements(<span class="hljs-string">&quot;Apache Flink is an open source platform for &quot;</span> +<br>      <span class="hljs-string">&quot;distributed stream and batch data processing&quot;</span>,<br>      <span class="hljs-string">&quot;Flink’s core is a streaming dataflow engine that provides data distribution&quot;</span>)<br>    <span class="hljs-comment">// 大致思路：对每行语句按照空格进行切分，切分之后组成（单词，1）tuple,按照单词分组最后进行聚合计算</span><br>    <span class="hljs-comment">// 3.指定这些数据的转换， transformation</span><br>    <span class="hljs-keyword">val</span> wordsDs: <span class="hljs-type">DataSet</span>[<span class="hljs-type">String</span>] = sourceDs.flatMap(_.split(<span class="hljs-string">&quot; &quot;</span>))<br>    <span class="hljs-comment">//(单词，1)</span><br>    <span class="hljs-keyword">val</span> wordAndOneDs: <span class="hljs-type">DataSet</span>[(<span class="hljs-type">String</span>, <span class="hljs-type">Int</span>)] = wordsDs.map((_, <span class="hljs-number">1</span>))<br>    <span class="hljs-keyword">val</span> groupDs: <span class="hljs-type">GroupedDataSet</span>[(<span class="hljs-type">String</span>, <span class="hljs-type">Int</span>)] = wordAndOneDs.groupBy(<span class="hljs-number">0</span>)<br>    <span class="hljs-comment">//聚合</span><br>    <span class="hljs-keyword">val</span> aggDs: <span class="hljs-type">AggregateDataSet</span>[(<span class="hljs-type">String</span>, <span class="hljs-type">Int</span>)] = groupDs.sum(<span class="hljs-number">1</span>)<br>    <span class="hljs-comment">// 4.指定将计算结果放在哪里，</span><br>    aggDs.writeAsText(<span class="hljs-string">&quot;hdfs://node1:8020/wc/out1&quot;</span>, <span class="hljs-type">FileSystem</span>.<span class="hljs-type">WriteMode</span>.<span class="hljs-type">OVERWRITE</span>)<br>    <span class="hljs-comment">//关于默认的并行度：默认获取的是当前机器的cpu核数是8，所以有8个结果文件，</span><br>    <span class="hljs-comment">// 5 触发程序执行</span><br>    env.execute()<br>  &#125;<br>&#125;<br><br></code></pre></td></tr></table></figure>


<p>提交任务到flink集群或者on yarn模式运行</p>
<p>1 打包程序</p>
<p>2 上传程序到linux中</p>
<p>3 on yarn模式，使用flink run 命令提交任务</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">flink run -m yarn-cluster -yn 2 -yjm 1024 -ytm 1024 -c cn.itcast.flink.batch.WordCountDemo /root/wc.jar<br></code></pre></td></tr></table></figure>



            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/myblog/categories/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%BC%80%E5%8F%91/">大数据开发</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/myblog/tags/%E5%A4%A7%E6%95%B0%E6%8D%AE/">大数据</a>
                    
                      <a class="hover-with-bg" href="/myblog/tags/flink/">flink</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                  </article>
                </div>
              
            </div>

            
              <!-- Comments -->
              <article class="comments" id="comments">
                
                
  <div id="vcomments"></div>
  <script type="text/javascript">
    Fluid.utils.waitElementVisible('vcomments', function() {
      Fluid.utils.createScript('https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js', function () {
        new Valine({
          el: "#vcomments",
          app_id: "E7q0fduNs9CsloEsT36P86kH-gzGzoHsz",
          app_key: "4HbzIz08PfCF6i0R4CKQlK9H",
          placeholder: "说点什么",
          path: window.location.pathname,
          avatar: "retro",
          meta: ["nick","mail","link"],
          pageSize: "10",
          lang: "zh-CN",
          highlight: false,
          recordIP: false,
          serverURLs: "",
        });
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the
    <a target="_blank" href="https://valine.js.org" rel="nofollow noopener noopener">comments powered by Valine.</a>
  </noscript>


              </article>
            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Search</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">keyword</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>

<!-- SCRIPTS -->

  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" ></script>
<script  src="/myblog/js/debouncer.js" ></script>
<script  src="/myblog/js/events.js" ></script>
<script  src="/myblog/js/plugins.js" ></script>

<!-- Plugins -->


  
    <script  src="/myblog/js/lazyload.js" ></script>
  



  



  <script  src="https://cdn.jsdelivr.net/npm/tocbot@4.12.0/dist/tocbot.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4.3.0/anchor.min.js" ></script>



  <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js" ></script>






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
      typing(title)
      
    })(window, document);
  </script>



  <script  src="/myblog/js/local-search.js" ></script>
  <script>
    (function () {
      var path = "/myblog/local-search.xml";
      var inputArea = document.querySelector("#local-search-input");
      inputArea.onclick = function () {
        searchFunc(path, 'local-search-input', 'local-search-result');
        this.onclick = null
      }
    })()
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/myblog/js/boot.js" ></script>



</body>
</html>
